using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class ListImageInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			IMG,
			IDProducts,
			Name,
			NameVN,
			IDNews
		}
		private Int32 _ID;
		private String _IMG;
		private Int64 _IDProducts;
		private String _Name;
		private String _NameVN;
		private Int32 _IDNews;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String IMG{	get{ return _IMG;} set{_IMG = value;} }
		public Int64 IDProducts{	get{ return _IDProducts;} set{_IDProducts = value;} }
		public String Name{	get{ return _Name;} set{_Name = value;} }
		public String NameVN{	get{ return _NameVN;} set{_NameVN = value;} }
		public Int32 IDNews{	get{ return _IDNews;} set{_IDNews = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public ListImageInfo()
		{
			_ID = 0;
			_IMG = "";
			_IDProducts = 0;
			_Name = "";
			_NameVN = "";
			_IDNews = 0;
		}
		public ListImageInfo(
		Int32 ID,
		String IMG,
		Int64 IDProducts,
		String Name,
		String NameVN,
		Int32 IDNews
		)
		{
			_ID = ID;
			_IMG = IMG;
			_IDProducts = IDProducts;
			_Name = Name;
			_NameVN = NameVN;
			_IDNews = IDNews;
		}
		public ListImageInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_IMG = dr[Field.IMG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.IMG.ToString()]);
				_IDProducts = dr[Field.IDProducts.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.IDProducts.ToString()]);
				_Name = dr[Field.Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Name.ToString()]);
				_NameVN = dr[Field.NameVN.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NameVN.ToString()]);
				_IDNews = dr[Field.IDNews.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.IDNews.ToString()]);
			}
		}
		public ListImageInfo(ListImageInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_IMG = objEntr.IMG;			
			_IDProducts = objEntr.IDProducts;			
			_Name = objEntr.Name;			
			_NameVN = objEntr.NameVN;			
			_IDNews = objEntr.IDNews;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("ListImage");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.IMG.ToString(), typeof(String)),
				new DataColumn(Field.IDProducts.ToString(), typeof(Int64)),
				new DataColumn(Field.Name.ToString(), typeof(String)),
				new DataColumn(Field.NameVN.ToString(), typeof(String)),
				new DataColumn(Field.IDNews.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.IMG.ToString()] = _IMG;
			row[Field.IDProducts.ToString()] = _IDProducts;
			row[Field.Name.ToString()] = _Name;
			row[Field.NameVN.ToString()] = _NameVN;
			row[Field.IDNews.ToString()] = _IDNews;
			return row;
		}
        #endregion InitTable
    }
}
